package com.ruoyi.project.cms.taskdelayask.controller;

import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.cms.task.domain.Assignment;
import com.ruoyi.project.cms.taskdelayask.domain.Delayapply;
import com.ruoyi.project.cms.taskdelayask.service.DelayapplyService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("/cms/taskdelayask")
public class taskdelayaskController extends BaseController {

    private String prefix = "cms/taskdelayask";

    @Autowired
    private DelayapplyService delayapplyService;


    @GetMapping("/delayask")
    public String taskdelayask()
    {
        return prefix + "/delayask";
    }

    @RequiresPermissions("monitor:operlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Delayapply delayapply, String roleName)
    {
        startPage();
        List<Delayapply> list = delayapplyService.selectAll(delayapply,roleName);
        return getDataTable(list);

    }

    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    @PostMapping("/addSave")
    @ResponseBody
    public AjaxResult addSave(@Validated Delayapply delayapply)
    {


        return toAjax(delayapplyService.addSava(delayapply));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("system:assignment:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(int ids)
    {
        return toAjax(delayapplyService.delect(ids));
    }


    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        Delayapply delayapply = delayapplyService.selectOne(id);
        mmap.put("delayapply",  delayapply);
        return prefix + "/edit";
    }

    @PostMapping("/editSave")
    @ResponseBody
    public AjaxResult editSave(Delayapply delayapply)
    {

        return toAjax(delayapplyService.update(delayapply));
    }
}
